package com.hp.bon.sgw.wh.channel.groupConsistency;

import com.alipay.api.internal.util.StringUtils;
import com.hp.bon.sgw.wh.channel.common.BizConsts;
import com.hp.bon.sgw.wh.channel.common.BizParam;
import com.hp.bon.sgw.wh.service.UserResourceConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConsistencyConfigLoader {


    private static final Logger _log = LoggerFactory.getLogger(ConsistencyConfigLoader.class);

    public BizParam doLoader(BizParam bizParam) {

        String requestPath = bizParam.getParamString(BizConsts.KEY_REQUEST_PATH);

        if (BizConsts.VALUE_PATH_QRY_RETURN_BALANCE_DETAIL.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryReturnBalanceDetail");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryReturnBalanceDetail");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_RETURN_BALANCE_INFO_DETAIL.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryReturnBalanceInfoDetail");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryReturnBalanceInfoDetail");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_BALANCE_RECORD.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryBalanceRecord");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryBalanceRecord");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_BALANCE_RECORD_DETAIL.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryBalanceRecordDetail");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryBalanceRecordDetail");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QUERY_BALANCE.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryBalance");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryBalance");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_PAYMENT.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryPayment");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryPayment");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_BILL.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryBill");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_QryBill");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_ACCU_USE_QRY.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_AccuUseQry");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_AccuUseQry");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_ACCU_USE_DETAIL_QRY.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_AccuUseDetailQry");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_AccuUseQry");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_CUST_BILL.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryCustBill");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_AccuUseQry");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_QRY_INSTANT_FEE_LIST.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_QryInstantFeeList");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_AccuUseQry");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        } else if (BizConsts.VALUE_PATH_CREDIT_PROD_FEE.equals(requestPath)) {
            String accountApiUrl = UserResourceConfigService.getValue("Api_CreditProdFee");
            if (StringUtils.isEmpty(accountApiUrl)) {
                _log.error("none accountApiUrl of Api_AccuUseQry");
            } else {
                bizParam.setParam(BizConsts.KEY_ACCOUNT_API_URL, accountApiUrl);
            }
        }

        return bizParam;
    }


}
